#include <Logger.h>

Logger::Logger(const string &TAG) : spdlog::logger(TAG) {
    //TODO 从文件中读取日志配置
    Logger::Sinks sins_type = Sinks::Console;
    spdlog::level::level_enum console = spdlog::level::level_enum::info;
    spdlog::level::level_enum file = spdlog::level::level_enum::off;
    //

    if (sins_type == Sinks::Both or sins_type == Sinks::Console) {
        auto console_sink = make_shared<spdlog::sinks::stdout_color_sink_mt>();
        console_sink->set_pattern(console_logger_pattern);
        console_sink->set_level(console);
        this->sinks_.emplace_back(console_sink);
    }
    if (sins_type == Sinks::Both or sins_type == Sinks::File) {
        auto file_sink = make_shared<spdlog::sinks::basic_file_sink_mt>("./log/" + TAG, true);
        file_sink->set_pattern(file_logger_pattern);
        file_sink->set_level(file);
        this->sinks().emplace_back();
    }
}

